﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LeadExpress.Models.ViewPages;

namespace LeadExpress.Areas.MyAccount.Controllers
{
    public class DashboardController : Controller
    {
        // Create an instance of user manage
        LeadExpress.Repository.DashboardManagementRepository repository = new LeadExpress.Repository.DashboardManagementRepository();

        #region #Product Dashboard
        // GET: /Management/Dashboard/
        [Authorize(Roles = "ClientAdmin")]
        public ActionResult Index()
        {
            DashboardManagementModel model = new DashboardManagementModel();
            var user = new Repository.UserRepository().GetSingle(User.Identity.Name);

            model = repository.GetModelByUser(user.ID, Helpers.Constant.HOME, "ClientAdmin");

            return View(model);
        }

        [Authorize(Roles = "ClientAdmin")]
        public ActionResult GetProduct(string startDate)
        {
            DashboardManagementModel model = new DashboardManagementModel();

            var user = new Repository.UserRepository().GetSingle(User.Identity.Name);
            DateTime currentDate = DateTime.Parse(startDate);

            model = repository.GetModelByUser(user.ID, currentDate);

            return Json(model);
        }

        // Ajax function post
        [Authorize(Roles = "ClientAdmin")]
        public ActionResult ProductFolow()
        {
            DashboardManagementModel model = new DashboardManagementModel();
            model = repository.GetModel("PRODUCT");

            return Json(model);
        }
        #endregion
    }
}
